//
// itertool - a polynormial and type-safe iterator framework in C++.
//
// Copyright (c) 2021-2025 Feng Cong
//
// Distributed under the MIT Software License
// See accompanying file LICENSE.txt or copy at
// https://opensource.org/licenses/MIT

#include "natural_number.h"

#include <iterator>
#include <numeric>
#include <vector>

#include "itertool_test.h"

TEST_CASE("NaturalNumber") {
  const int kLimit = 10;
  auto nr = itertool_test::NaturalNumber(kLimit);

  SUBCASE("It is finite and runs specific times") {
    CHECK(nr.IsFinite());
    CHECK_EQ(std::distance(nr.begin(), nr.end()), kLimit);
  }

  SUBCASE("It should generate natural number sequence") {
    std::vector<int> a(kLimit);
    // Fill a.
    std::iota(a.begin(), a.end(), 0);

    // Fill b.
    std::vector<int> b;
    std::copy(nr.begin(), nr.end(), std::back_inserter(b));

    CHECK_EQ(a, b);
  }

  SUBCASE("It is resetable") {  //
    CHECK(nr.IsResetable());
  }
}
